package com.itmiaojie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itmiaojie.mapper.TagMapper;
import com.itmiaojie.pojo.ResponseResult;
import com.itmiaojie.pojo.Tag;
import com.itmiaojie.pojo.dto.TagDto;
import com.itmiaojie.pojo.vo.TagVo;
import com.itmiaojie.service.TagService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


/**
 *
 */
@Service
public class TagServiceImpl extends ServiceImpl<TagMapper, Tag>
    implements TagService {

    @Override
    public ResponseResult pageTagList(Integer pageNum, Integer pageSize, TagDto tagDto) {

        IPage<Tag> page= new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<Tag> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(StringUtils.hasText(tagDto.getName()),Tag::getName,tagDto.getName());
        queryWrapper.eq(StringUtils.hasText(tagDto.getRemark()),Tag::getRemark,tagDto.getRemark());
        page(page,queryWrapper);
        return ResponseResult.okResult(new TagVo(page.getRecords(),page.getTotal()));
    }
}




